//设备列表
function refresh(){
	allEqlist();
}

$(allEqlist);
function allEqlist(){
	var eqids = ["KGG","XB","NBQ","QXY"];
	$.each(eqids,function(){
		try{
			listEqs(this,this=='NBQ'?$('.searthnbq').val():'');
		}catch(e){
			
		}
	})
};

var snameclass = ["","bg-or","bg-3fb","bg-green"];
var psid = param.psid;
var dataHand = new AjaxHandler();
var statedesc = ['','正常运行','正常停机','告警运行','故障停机','通讯中断'];
function listEqs(eqtype,words){
	$.proAjax({
		url:"/mobile/eqlists/"+eqtype,
		data:{psid:psid,keywords:words},
		success: function (data){
			dataHand.arrayAddToHtml("model-"+eqtype,data,"other-"+eqtype,function(elm,datas){
				if("KGG"==eqtype)elm.find("#sname").addClass(snameclass[datas.kggtype]);
				if('NBQ'==eqtype){
					elm.attr("nbqtype",datas.nbqtype);
					elm.attr("nbqname",datas.name);
					elm.find("#sname").addClass("nbq-bg"+datas.state);
					elm.find("#statedesc").addClass("nbq-col"+datas.state);
					elm.find("#statedesc").text(statedesc[datas.state]);
				}
				elm.attr("data-type",datas.type);
				elm.attr("data-eqid",datas.eqid);
				elm.attr("data-cid",datas.cid);
				elm.on('click',cld);
			});
		}
	});
}
mui(".mui-indexed-list-search").on("tap",".mui-icon-clear",function(e){
	listEqs("NBQ");
});
function cld(e){
	$(".searthnbq").val("");
	e.preventDefault();
	e.stopPropagation();
	router.href($(this).find("a").attr("href"),{type:$(this).attr("data-type"),
		eqid:$(this).attr("data-eqid"),
		cid:$(this).attr("data-cid"),
		nbqtype:$(this).attr("nbqtype"),
		nbqname:$(this).attr("nbqname")
	});
}

function searchd(value){
	listEqs("NBQ",value);
}